home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / netbon.zip / FULLNAME.PAS next >
Pascal/Delphi Source File  |  1990-05-03  |  4KB  |  94 lines

  1. {*********************************************************************}
  2. {* FULLNAME - Program to display NetWare user's full name            *}
  3. {* version 1.0 1/13/90                                               *}
  4. {* by Richard Sadowsky                                               *}
  5. {*                                                                   *}
  6. {* USAGE: FULLNAME [UserName]                                        *}
  7. {*                                                                   *}
  8. {*   UserName is the name of the user to return full name for.       *}
  9. {*   If no UserName specified, program will prompt for one.          *}
  10. {*                                                                   *}
  11. {*                                                                   *}
  12. {* This program requires the NETWARE unit from B-Tree Filer from     *}
  13. {* TurboPower Software (408) 438-8608.                               *}
  14. {*                                                                   *}
  15. {* Also requires the NETBIND unit.                                   *}
  16. {*                                                                   *}
  17. {* Please address questions and comments about this unit to ALL in   *}
  18. {* section 6 of the PCVENB forum on Compuserve.                      *}
  19. {*                                                                   *}
  20. {*********************************************************************}
  21. {$V-,S-,R-}
  22. program FullName;
  23.  
  24. {** define the following conditional to use with OPRO, undefine for TPRO}
  25. {$DEFINE UseOPRO}
  26. uses
  27.   {$IFDEF UseOPRO}
  28.   OpString,
  29.   {$ELSE}
  30.   TpString,
  31.   {$ENDIF}
  32.   NetWare,
  33.   NetBind;
  34.  
  35. const
  36.   FullNamePropName = 'IDENTIFICATION'; {the property name of the full name}
  37.  
  38. var
  39.   ObjName          : ObjNameStr;
  40.   HasProperties    : Boolean;
  41.   ObjType          : Word;
  42.   ObjID            : LongInt;
  43.   ObjFlag, ObjSec  : Byte;
  44.   Result           : Byte;
  45.   PropVal          : PropertyValueType;
  46.  
  47. begin
  48.   {if command line parameter specified, then use it as the user name}
  49.   if ParamCount > 0 then
  50.     {uppercase the parameter}
  51.     ObjName := StUpCase(ParamStr(1))
  52.   else begin
  53.     {prompt for user name}
  54.     Write('Enter user name: ');
  55.     ReadLn(ObjName);
  56.     ObjName := StUpCase(ObjName);
  57.   end;
  58.   {if no ObjName, then just quit}
  59.   if Length(ObjName) = 0 then
  60.     Halt;
  61.  
  62.   ObjType := bindUser;            {look for an user object}
  63.   ObjID   := -1;                  {indicate start of search}
  64.   {scan the bindery for the object}
  65.   Result := ScanObject(ObjType, ObjName, ObjID, ObjFlag,
  66.                        ObjSec, HasProperties);
  67.   case Result of
  68.     $00 : ;                       {No error}
  69.     $FC : begin                   {No such user}
  70.             WriteLn('There is no user ', ObjName, ' defined');
  71.             Halt;
  72.           end;
  73.     else begin                    {other bindery error}
  74.       WriteLn('Bindery error scanning object = ',Result);
  75.       Halt;
  76.     end;
  77.   end;
  78.   {if the user object has no properties, then no full name is defined for user}
  79.   if not HasProperties then begin
  80.     WriteLn('No full name defined for user ', ObjName);
  81.     Halt;
  82.   end;
  83.  
  84.   {Attempt to read the property value for IDENTIFICATION to return full name}
  85.   Result := ReadPropertyValue(ObjType, ObjName, 1, FullNamePropName, PropVal,
  86.                               ObjFlag, HasProperties);
  87.   case Result of
  88.     $00 : WriteLn('Full Name: ', AsciiZ2Str(PropVal, SizeOf(PropVal)-1));
  89.     $F1, $F9 : WriteLn('You do not have adequate bindery rights to read the user''s full name');
  90.     $FB : WriteLn('No full name defined for user ', ObjName);
  91.     else WriteLn('Bindery error reading property value = ',Result);
  92.   end;
  93. end.
  94.